<?xml version="1.0" encoding="UTF-8"?>

<!-- Copyright 2007 XBRL International. All Rights Reserved. -->

<link:linkbase
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xmlns:link="http://www.xbrl.org/2003/linkbase"
  xmlns:generic="http://xbrl.org/2008/generic"
  xmlns:formula="http://xbrl.org/2008/formula"
  xmlns:variable="http://xbrl.org/2008/variable"
  xmlns:cf="http://xbrl.org/2008/filter/concept"
  xmlns:gf="http://xbrl.org/2008/filter/general"
  xmlns:pf="http://xbrl.org/2008/filter/period"
  xmlns:xfi="http://www.xbrl.org/2008/function/instance" 
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" 
  xmlns:test="http://abc.com/test"
  xmlns:xbrli="http://www.xbrl.org/2003/instance"

  xsi:schemaLocation="
  http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-2003-12-31.xsd
  http://xbrl.org/2008/generic ../../core_schemas/generic-link.xsd
  http://xbrl.org/2008/formula ../../core_schemas/formula.xsd
  http://xbrl.org/2008/variable ../../core_schemas/variable.xsd
  http://xbrl.org/2008/filter/concept ../../core_schemas/concept-filter.xsd
  http://xbrl.org/2008/filter/period ../../core_schemas/period-filter.xsd
  http://xbrl.org/2008/filter/general ../../core_schemas/general-filter.xsd
  ">
  
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-set" xlink:href="../../core_schemas/variable.xsd#variable-set" xlink:type="simple"/>
  <link:arcroleRef arcroleURI="http://xbrl.org/arcrole/2008/variable-filter" xlink:href="../../core_schemas/variable.xsd#variable-filter" xlink:type="simple"/>
  <link:roleRef roleURI="http://www.xbrl.org/2008/role/link" xlink:href="../../core_schemas/generic-link.xsd#standard-link-role" xlink:type="simple"/>

  <generic:link xlink:type="extended"
    xlink:role="http://www.xbrl.org/2008/role/link">

    <formula:formula xlink:type="resource" xlink:label="formula" 
      value="$inst2item - $inst1item"
      source="inst1item"
      aspectModel="non-dimensional" implicitFiltering="true">
      <formula:decimals>0</formula:decimals>
    </formula:formula>

    <!-- function xfi:xbrl-instance -->
    <variable:function xlink:type="resource" xlink:label="xbrl-instance"
       name="xfi:xbrl-instance"
       output="element(xbrli:xbrl)">
         <!-- href -->
         <variable:input type="xs:anyURI" />
    </variable:function>

    <!-- an item from instance 1 -->
    <variable:factVariable xlink:type="resource" xlink:label="inst1item" bindAsSequence="false" />

    <!--  Arc from the formula to the variables it depends on -->
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formula" xlink:to="inst1item" order="1.0"
      name="inst1item" />


    <!-- general variable is alternate instance document -->
    <variable:generalVariable xlink:type="resource" xlink:label="inst2" bindAsSequence="false"
      select="xfi:xbrl-instance('xbrl-inst-facts-instance2.xml')" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formula" xlink:to="inst2" order="1.0"
      name="inst2" />

    <!-- general variable is each fact in alternate instance document -->
    <variable:generalVariable xlink:type="resource" xlink:label="inst2item" bindAsSequence="false"
      select="$inst2//*[if (namespace-uri() eq 'http://abc.com/test2' and
                            local-name() eq local-name($inst1item))
                       then ((xfi:period-instant( xfi:period($inst1item) ) + xs:yearMonthDuration('P1Y')) eq
                             xfi:period-instant( xfi:period(.) ) )
                       else false()
                       ]" />
    <variable:variableArc xlink:type="arc" xlink:arcrole="http://xbrl.org/arcrole/2008/variable-set" 
      xlink:from="formula" xlink:to="inst2item" order="1.0"
      name="inst2item" />

  </generic:link>

</link:linkbase>


